#
# Copyright (C) [2024] Xingyun Integrated Circuit, Inc.
#
# GreenCode was a private technology asset of Xingyun Integrated Circuit， Inc （Confidential）
# Author: Shawn.Tan
# Date: 2025.10.28
#
# History: Initial Version 2025.10.28
#
#
from DV.gpgpu.trees.instruction_tree import (
    ALU_Int_All_instructions,
    ALU_Int32_All_instructions,
)
from base.Sequence import Sequence
from gpgpu.EnvGPGPU import EnvGPGPU
from gpgpu.GenThreadGPGPU import GenThreadGPGPU


class MyMainSequence(Sequence):
    def generate(self, **kargs):
        loopCount, valid = self.getOption("loopCount")

        if not valid:
            self.error(
                ">>>>>  No 'loopCount' option was specified.  Value is {}.".format(loopCount)
            )
        else:
            self.notice(">>>>>  Value specified for 'loopCount' option is:  {}".format(loopCount))

        instrs = (
            ALU_Int32_All_instructions
            if self.getGlobalState("AppRegisterWidth") == 32
            else ALU_Int_All_instructions
        )

        for _ in range(loopCount):
            instr = self.pickWeighted(instrs)
            self.genInstruction(instr)


MainSequenceClass = MyMainSequence
GenThreadClass = GenThreadGPGPU
EnvClass = EnvGPGPU
